Persing of DailyTicket entry in tariff-file

This commit is contained in:
Gerhard Hoffmann 2024-01-30 10:44:25 +01:00
parent 4c1cd45866
commit 8aa9aa497a

View File

@ -214,53 +214,55 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
DailyTicket.daily_ticket_payment_option_id = k->value.GetInt(); DailyTicket.daily_ticket_payment_option_id = k->value.GetInt();
} }
} else } else
if (QString(inner_obj_name) == QString("daily_ticket_unit_id")) { if (QString(inner_obj_name) == QString("daily_ticket_id")) {
if (k->value.IsInt()) { if (k->value.IsInt()) {
DailyTicket.daily_ticket_unit_id = k->value.GetInt(); DailyTicket.daily_ticket_id = k->value.GetInt();
} }
} else } else
if (QString(inner_obj_name) == QString("daily_ticket_price")) { if (QString(inner_obj_name) == QString("daily_ticket_price_id")) {
if (k->value.IsInt()) { if (k->value.IsInt()) {
DailyTicket.daily_ticket_price = k->value.GetInt(); DailyTicket.daily_ticket_price_id = k->value.GetInt();
} }
} else } else
if (QString(inner_obj_name) == QString("daily_ticket_tbase_type")) { if (QString(inner_obj_name) == QString("daily_ticket_tb_id")) {
if (k->value.IsInt()) { if (k->value.IsInt()) {
int baseType = k->value.GetInt(); DailyTicket.daily_ticket_tb_id = k->value.GetInt();
switch(baseType) { }
case (int)ATBTimeBase::TimeBaseType::ABSOLUTE: } else
DailyTicket.daily_ticket_tbase_type = ATBTimeBase::TimeBaseType::ABSOLUTE; if (QString(inner_obj_name) == QString("daily_ticket_clearance_customer_ids")) {
break; if (k->value.IsArray()) {
case (int)ATBTimeBase::TimeBaseType::RELATIVE: auto customerIds = k->value.GetArray();
DailyTicket.daily_ticket_tbase_type = ATBTimeBase::TimeBaseType::RELATIVE; for (rapidjson::SizeType i=0; i < customerIds.Size(); ++i) {
break; if (customerIds[i].IsInt()) {
DailyTicket.daily_ticket_clearance_customer_ids.append(customerIds[i].GetInt());
}
} }
} }
} else } else
if (QString(inner_obj_name) == QString("daily_ticket_clearance_customer_type")) { if (QString(inner_obj_name) == QString("daily_ticket_from_min")) {
if (k->value.IsInt()) { if (k->value.IsString()) {
int CustomerType = k->value.GetInt(); std::string const from_min = k->value.GetString();
switch (CustomerType) { char const *from_min_c_str = from_min.c_str(); // for debugging
case (int)ATBCustomer::CustomerType::ADULT: DailyTicket.daily_ticket_from_min = QTime::fromString(from_min_c_str, Qt::ISODate);
DailyTicket.daily_ticket_clearance_customer_type = ATBCustomer::CustomerType::ADULT;
break;
case (int)ATBCustomer::CustomerType::CHILD:
DailyTicket.daily_ticket_clearance_customer_type = ATBCustomer::CustomerType::CHILD;
break;
case (int)ATBCustomer::CustomerType::TEEN:
DailyTicket.daily_ticket_clearance_customer_type = ATBCustomer::CustomerType::TEEN;
break;
}
} }
} else } else
if (QString(inner_obj_name) == QString("daily_ticket_weekday_range")) { if (QString(inner_obj_name) == QString("daily_ticket_to_max")) {
if (k->value.IsInt()) { if (k->value.IsString()) {
DailyTicket.daily_ticket_weekday_range = k->value.GetInt(); std::string const to_max = k->value.GetString();
char const *to_max_c_str = to_max.c_str();
DailyTicket.daily_ticket_to_max = QTime::fromString(to_max_c_str, Qt::ISODate);
} }
} else } else
if (QString(inner_obj_name) == QString("daily_ticket_special_day_range")) { if (QString(inner_obj_name) == QString("daily_ticket_from_offset_min")) {
if (k->value.IsInt()) { if (k->value.IsInt()) {
DailyTicket.daily_ticket_special_day_range = k->value.GetInt(); int const from_offset_min = k->value.GetInt();
DailyTicket.daily_ticket_from_offset_min = from_offset_min;
}
} else
if (QString(inner_obj_name) == QString("daily_ticket_to_offset_max")) {
if (k->value.IsInt()) {
int to_offset_max = k->value.GetInt();
DailyTicket.daily_ticket_to_offset_max = to_offset_max;
} }
} }
break; break;
@ -410,7 +412,9 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
cfg->YearPeriod.insert(pair<int, ATBPeriodYear>(YearPeriod.pye_id, YearPeriod)); cfg->YearPeriod.insert(pair<int, ATBPeriodYear>(YearPeriod.pye_id, YearPeriod));
break; break;
case MemberType::DailyTicketType: case MemberType::DailyTicketType:
// qCritical() << DailyTicket; cfg->DailyTicket.insert(pair<int, ATBDailyTicket>(DailyTicket.daily_ticket_id, DailyTicket));
qCritical() << DailyTicket;
DailyTicket.reset();
break; break;
case MemberType::CustomerType: case MemberType::CustomerType:
// qCritical() << Customer; // qCritical() << Customer;