Added getPaymentOptionIndex() and getPaymentOptionsForAllKeys()
This commit is contained in:
parent
070446d01a
commit
0bfec6a938
@ -765,7 +765,7 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
|
|||||||
}
|
}
|
||||||
} break;
|
} 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));
|
||||||
// qCritical() << Duration;
|
// qCritical() << Duration;
|
||||||
break;
|
break;
|
||||||
case MemberType::SpecialDaysWorktimeType:
|
case MemberType::SpecialDaysWorktimeType:
|
||||||
@ -1131,6 +1131,37 @@ Configuration::getTariffProductForProductTypeName(QString const &permitTypeName)
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Configuration::getPaymentOptionIndex(PERMIT_TYPE permitType) {
|
||||||
|
|
||||||
|
std::optional<QVector<ATBPaymentOption>> paymentOptions = getPaymentOptionsForAllKeys();
|
||||||
|
if (paymentOptions) {
|
||||||
|
QVector<ATBPaymentOption> const vec = paymentOptions.value();
|
||||||
|
PermitType const p(permitType);
|
||||||
|
for (int i = 0; i < vec.size(); ++i) {
|
||||||
|
if (vec[i].pop_product_name == p.toString()) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Configuration::getPaymentOptionIndex(PERMIT_TYPE permitType) const {
|
||||||
|
std::optional<QVector<ATBPaymentOption>> paymentOptions = getPaymentOptionsForAllKeys();
|
||||||
|
if (paymentOptions) {
|
||||||
|
QVector<ATBPaymentOption> const vec = paymentOptions.value();
|
||||||
|
PermitType const p(permitType);
|
||||||
|
for (int i = 0; i < vec.size(); ++i) {
|
||||||
|
if (vec[i].pop_product_name == p.toString()) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
std::optional<QVector<ATBTariffProduct>>
|
std::optional<QVector<ATBTariffProduct>>
|
||||||
Configuration::getTariffProductForProductId(PermitType permitType) const {
|
Configuration::getTariffProductForProductId(PermitType permitType) const {
|
||||||
QString permitTypeName(permitType);
|
QString permitTypeName(permitType);
|
||||||
@ -1240,6 +1271,49 @@ Configuration::getDailyTicketsForKey(int key) const {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::optional<QVector<ATBPaymentOption>>
|
||||||
|
Configuration::getPaymentOptionsForAllKeys() const {
|
||||||
|
QVector<ATBPaymentOption> paymentOptions;
|
||||||
|
std::optional<QVector<ATBPaymentOption>> value;
|
||||||
|
for (std::multimap<int, ATBPaymentOption>::const_iterator it = this->PaymentOption.cbegin();
|
||||||
|
it != this->PaymentOption.cend(); ++it) {
|
||||||
|
paymentOptions.append(it->second);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (paymentOptions.size() > 0) {
|
||||||
|
value = value.value_or(paymentOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<ATBPaymentOption>
|
||||||
|
Configuration::getPaymentOptionForKey(PERMIT_TYPE permitType) const {
|
||||||
|
return getPaymentOptionForKey(static_cast<int>(permitType));
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<ATBPaymentOption>
|
||||||
|
Configuration::getPaymentOptionForKey(int permitType) const {
|
||||||
|
std::optional<ATBPaymentOption> value;
|
||||||
|
|
||||||
|
for (std::multimap<int, ATBPaymentOption>::const_iterator it = this->PaymentOption.cbegin();
|
||||||
|
it != this->PaymentOption.cend(); ++it) {
|
||||||
|
ATBPaymentOption const &paymentOption = it->second;
|
||||||
|
if (paymentOption.pop_product_id == permitType) {
|
||||||
|
value = value.value_or(paymentOption);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<ATBPaymentOption>
|
||||||
|
Configuration::getPaymentOptionForKey(QString const &permitTypeStr) const {
|
||||||
|
PERMIT_TYPE permitType = PermitType::toPermitType(permitTypeStr);
|
||||||
|
return getPaymentOptionForKey(static_cast<int>(permitType));
|
||||||
|
}
|
||||||
|
|
||||||
std::optional<QVector<ATBPaymentRate>>
|
std::optional<QVector<ATBPaymentRate>>
|
||||||
Configuration::getPaymentRateForAllKeys() const {
|
Configuration::getPaymentRateForAllKeys() const {
|
||||||
QVector<ATBPaymentRate> paymentRates;
|
QVector<ATBPaymentRate> paymentRates;
|
||||||
|
Loading…
Reference in New Issue
Block a user