Removed local variable PaymentOption. Replaced by usage of currentPaymentOption-vector.

This commit is contained in:
Gerhard Hoffmann 2024-01-30 14:04:58 +01:00
parent dbcd27b377
commit c799c24658

View File

@ -87,7 +87,6 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
ATBSpecialDays SpecialDays;
ATBWeekDays WeekDays;
ATBWeekDaysWorktime WeekDaysWorktime;
ATBPaymentOption PaymentOption;
ATBPeriodYear YearPeriod;
ATBDailyTicket DailyTicket;
ATBTimeBase TimeBase;
@ -96,6 +95,7 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
ATBTimeStepConfig TimeStepConfig;
MemberType mb_type = MemberType::UnknownType;
this->currentPaymentOptions.clear();
// Get all JSON object members
// This code should run only once (to load JSON variables into memory)
@ -320,22 +320,37 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
else if (strcmp(inner_obj_name, "pra_price") == 0) PaymentRate.pra_price = k->value.GetDouble();
break;
case MemberType::PaymentOptionType:
if (strcmp(inner_obj_name, "pop_id") == 0) PaymentOption.pop_id = k->value.GetInt();
else if (strcmp(inner_obj_name, "pop_label") == 0) PaymentOption.pop_label = k->value.GetString();
else if (strcmp(inner_obj_name, "pop_payment_method_id") == 0) PaymentOption.pop_payment_method_id = k->value.GetInt();
else if (strcmp(inner_obj_name, "pop_day_end_time") == 0) PaymentOption.pop_day_end_time = k->value.GetString();
else if (strcmp(inner_obj_name, "pop_day_night_end_time") == 0) PaymentOption.pop_day_night_end_time = k->value.GetString();
else if (strcmp(inner_obj_name, "pop_price_night") == 0) PaymentOption.pop_price_night = k->value.GetDouble();
else if (strcmp(inner_obj_name, "pop_min_time") == 0) PaymentOption.pop_min_time = k->value.GetDouble();
else if (strcmp(inner_obj_name, "pop_max_time") == 0) PaymentOption.pop_max_time = k->value.GetDouble();
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_carry_over_time_range_id") == 0) PaymentOption.pop_carry_over_time_range_id = k->value.GetInt();
else if (strcmp(inner_obj_name, "pop_daily_card_price") == 0) PaymentOption.pop_daily_card_price = k->value.GetInt();
else if (strcmp(inner_obj_name, "pop_business_hours") == 0) PaymentOption.pop_business_hours = k->value.GetInt();
else if (strcmp(inner_obj_name, "pop_time_step_config") == 0) PaymentOption.pop_time_step_config = k->value.GetInt();
this->currentPaymentOptions.append(PaymentOption);
PaymentOption.reset();
if (strcmp(inner_obj_name, "pop_id") == 0) {
this->currentPaymentOptions.append(ATBPaymentOption());
this->currentPaymentOptions.last().reset();
this->currentPaymentOptions.last().pop_id = k->value.GetInt();
} else if (strcmp(inner_obj_name, "pop_label") == 0) {
this->currentPaymentOptions.last().pop_label = k->value.GetString();
} else if (strcmp(inner_obj_name, "pop_payment_method_id") == 0) {
this->currentPaymentOptions.last().pop_payment_method_id = k->value.GetInt();
} else if (strcmp(inner_obj_name, "pop_day_end_time") == 0) {
this->currentPaymentOptions.last().pop_day_end_time = k->value.GetString();
} else if (strcmp(inner_obj_name, "pop_day_night_end_time") == 0) {
this->currentPaymentOptions.last().pop_day_night_end_time = k->value.GetString();
} else if (strcmp(inner_obj_name, "pop_price_night") == 0) {
this->currentPaymentOptions.last().pop_price_night = k->value.GetDouble();
} else if (strcmp(inner_obj_name, "pop_min_time") == 0) {
this->currentPaymentOptions.last().pop_min_time = k->value.GetDouble();
} else if (strcmp(inner_obj_name, "pop_max_time") == 0) {
this->currentPaymentOptions.last().pop_max_time = k->value.GetDouble();
} else if (strcmp(inner_obj_name, "pop_min_price") == 0) {
this->currentPaymentOptions.last().pop_min_price = k->value.GetDouble();
} else if (strcmp(inner_obj_name, "pop_carry_over") == 0) {
this->currentPaymentOptions.last().pop_carry_over = k->value.GetInt();
} else if (strcmp(inner_obj_name, "pop_carry_over_time_range_id") == 0) {
this->currentPaymentOptions.last().pop_carry_over_time_range_id = k->value.GetInt();
} else if (strcmp(inner_obj_name, "pop_daily_card_price") == 0) {
this->currentPaymentOptions.last().pop_daily_card_price = k->value.GetInt();
} else if (strcmp(inner_obj_name, "pop_business_hours") == 0) {
this->currentPaymentOptions.last().pop_business_hours = k->value.GetInt();
} else if (strcmp(inner_obj_name, "pop_time_step_config") == 0) {
this->currentPaymentOptions.last().pop_time_step_config = k->value.GetInt();
}
break;
case MemberType::DurationType:
if (strcmp(inner_obj_name, "pun_id") == 0) Duration.pun_id = k->value.GetInt();
@ -397,9 +412,12 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
// qCritical() << "PaymentRate" << PaymentRate;
cfg->PaymentRate.insert(pair<int, ATBPaymentRate>(PaymentRate.pra_payment_option_id, PaymentRate));
break;
case MemberType::PaymentOptionType:
case MemberType::PaymentOptionType: {
if (!this->currentPaymentOptions.isEmpty()) {
ATBPaymentOption const &PaymentOption = this->currentPaymentOptions.last();
cfg->PaymentOption.insert(pair<int, ATBPaymentOption>(PaymentOption.pop_payment_method_id, PaymentOption));
break;
}
} break;
case MemberType::DurationType:
cfg->Duration.insert(pair<int, ATBDuration>(Duration.pun_id, Duration));
break;
@ -453,10 +471,12 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
}
ATBPaymentOption const &Configuration::getPaymentOptions() const {
Q_ASSERT(!this->currentPaymentOptions.isEmpty());
return this->currentPaymentOptions.at(0);
}
ATBPaymentOption &Configuration::getPaymentOptions() {
Q_ASSERT(!this->currentPaymentOptions.isEmpty());
return this->currentPaymentOptions[0];
}