Implement getTariffProductForProductTypeName().

Use the type names of PERMIT_TYPE, not real indices as they can change.
This commit is contained in:
Gerhard Hoffmann 2024-04-30 13:48:03 +02:00
parent 7aded2b7fb
commit c1d5ffcf3c

View File

@ -717,6 +717,27 @@ Configuration::getTariffProductForAllKeys() const {
return value; return value;
} }
std::optional<QVector<ATBTariffProduct>>
Configuration::getTariffProductForProductTypeName(QString const &permitTypeName) const {
QVector<ATBTariffProduct> products;
std::optional<QVector<ATBTariffProduct>> value;
products.clear();
for(const auto &product: this->TariffProduct) {
ATBTariffProduct const &v = product.second;
if (v.m_tariff_product_name == permitTypeName) {
products.append(v);
}
}
if (products.size() > 0) {
value = value.value_or(products);
}
return value;
}
std::optional<QVector<ATBTariffProduct>> std::optional<QVector<ATBTariffProduct>>
Configuration::getTariffProductForProductId(PermitType permitType) const { Configuration::getTariffProductForProductId(PermitType permitType) const {
QVector<ATBTariffProduct> products; QVector<ATBTariffProduct> products;