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